package com.symria.server.dao.app;

import java.util.Date;
import java.util.List;

import com.symria.framework.dao.util.TemplateDao;
import com.symria.framework.page.Page;
import com.symria.framework.util.StringUtil;
import com.symria.server.po.AppInfo;
import com.symria.server.po.UserInfo;
import com.symria.system.constants.AppStatus;
import com.symria.system.statement.Statement;
import com.symria.system.statement.mysql.StatementFactoryImpl;
import com.symria.system.util.SessionHelper;

public class APPDao extends TemplateDao{

	public AppInfo findAppByName(String appName){
		
		Statement stm=stmsFactory.createStatement("from AppInfo a where a.appName = ?");
		stm.addParam(appName);
		return templateDao.find(stm, AppInfo.class);
	}
	
	
	public List<AppInfo> findAllApp(Integer userid){
		Statement smt=stmsFactory.createStatement("from AppInfo ap where ap.userId = ? and ap.status != ?");
		smt.addParam(userid);
		smt.addParam(AppStatus.STATUS_DEL.toString());
		return templateDao.query(smt);
	}
	
	
	public void searchApp(String appName,String appPlat,String appCate,String status,Integer userid,Page page){
		
		Statement stm=stmsFactory.createStatement("from AppInfo ap where ap.userId = ? and ap.status != ?");
		stm.addParam(userid);
		stm.addParam(AppStatus.STATUS_DEL.toString());
		stm.appendLike(null, "and", "ap.appName", appName);
		stm.append("and", "ap.appCate", "=", appCate);
		stm.append("and", "ap.status", "=", status);
		stm.append("and", "ap.appPlat", "=", appPlat);
		templateDao.search(stm, page);
		
	}
}
